import { DialogForm } from 'custom/index'
import { addShopDistributeRule, updateShopDistributeRule, getShopDistributeRuleDetail } from './api'
import RuleList from './components/RuleList.vue'

const addDialog = new DialogForm('DialogForm')

addDialog
  .title('新增')
  .postApi(addShopDistributeRule)
  .useGroup('')
    .useItem('ruleName').label('规则名称').required().end()
    .useCustomItem(RuleList, 'ruleList').setDefault([]).end()

const editDialog = new DialogForm('DialogForm')
editDialog
  .title('编辑')
  .getApi((_, row) => getShopDistributeRuleDetail({ ruleId: row.ruleId }))
  .postApi(updateShopDistributeRule)
  .useGroup('')
    .useItem('ruleName').label('规则名称').required().end()
    .useCustomItem(RuleList, 'ruleList').setDefault([]).end()

export { addDialog, editDialog }
